package DigiJoe;


public class Switch extends DigitalElement implements IInteractiveObject {

    //alapbol low
    private Sign state = Sign.Low;

    //konstruktor
    public Switch (int MaxOutputPort) {
        super(MaxOutputPort);
    }

    //getter a statenek
    public Sign getState() {return state;}

    @Override
    public void stepState() throws Exception{
        //state ellenkezoere allitas
        if(state == Sign.Low)
            state = Sign.High;
        else state = Sign.Low;

        //wirek updatelese
        for(int i = 0; i<outputList.size(); i++){
            for(Wire output : outputList.get(i)){
                output.setDigitalValue(state);
            }
        }
    }

    @Override
    public ElementType getType() {
        //tipus: switch
        return ElementType.Switch;
    }

}

